package org.edu.lazymodel;

import java.util.List;

import javax.faces.model.ListDataModel;

import org.edu.model.Student;
import org.primefaces.model.SelectableDataModel;

public class StudentDataModel extends ListDataModel<Student> implements SelectableDataModel<Student> {    
	  
    public StudentDataModel() {
    
    }  
  
    public StudentDataModel(List<Student> data) { 
    	super(data);
    }  
      
    @Override  
    public Student getRowData(String rowKey) {  
    	
        List<Student> data = (List<Student>) getWrappedData();  
        for(Student student : data) {  
            if(student.getUserStudent().getUser_number().equals(rowKey))  
                return student;  
        }  
          
        return null;  
    }  
  
    @Override  
    public Object getRowKey(Student student) {  
        return student.getUserStudent().getUser_number();  
    }  

}
